﻿using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.SystemUI;
using System;
using System.Drawing;
using System.Runtime.CompilerServices;
using System.Windows.Forms;
using DevComponents.DotNetBar;

namespace ZJGIS.Framework
{
    public class FrameworkClass : IFramework
    {
        #region User Deinfe
        public event OnDockWindowEventHandler OnDockWindowEvent;
        private object m_Hook;
        private object m_MainHook;
        private object m_SecondaryHook;

        private ITool m_Tool;
        private IAppInfo m_AppInfo;
        private Form m_Form;
        private Control m_Control;

        private IBarManager m_BarManager;
        private IDockManager m_DockManager;

        private IApplication m_Application = new ApplicationClass();
        private IStyleGallery m_StyleGallery = null;
        private bool m_Delay;
        #endregion

        #region Attribute
        public Control ActiveMapControl
        {
            get
            {
                return this.m_Control;
            }
            set
            {
                this.m_Control = value;
            }
        }

        public IAppInfo AppInfo
        {
            get
            {
                return this.m_AppInfo;
            }
            set
            {
                this.m_AppInfo = value;
            }
        }

        public IApplication Application
        {
            get
            {
                return this.m_Application;
            }
            set
            {
                this.m_Application = value;
            }
        }

        public IBarManager BarManager
        {
            get
            {
                return m_BarManager;
            }
            set
            {
                m_BarManager = value;
            }
        }

        public ITool CurrentTool
        {
            get
            {
                return m_Tool;
            }
            set
            {
                m_Tool = value;
            }
        }

        public IDockManager DockManager
        {
            get
            {
                return m_DockManager;
            }
            set
            {
                m_DockManager = value;
            }
        }

        public object Hook
        {
            get
            {
                return m_Hook;
            }
            set
            {
                m_Hook = value;
            }
        }

        public object MainHook
        {
            get
            {
                return m_MainHook;
            }
            set
            {
                m_MainHook = value;
            }
        }

        public Form MdiForm
        {
            get
            {
                return this.MdiForm;
            }
            set
            {
                this.MdiForm = value;
            }
        }

        public object SecondaryHook
        {
            get
            {
                return this.m_SecondaryHook;
            }
            set
            {
                this.m_SecondaryHook = value;
            }
        }

        //public IStyleGallery StyleGallery
        //{
        //    set
        //    {
        //        this.m_Application.StyleGallery = value;
        //    }
        //}
        #endregion

        public FrameworkClass()
        {
            IApplicationEvents events = this.m_Application as IApplicationEvents;
            events.OnDelayEvents += new OnDelayEventsChangedEventHandler(this.Application_OnDelayEvents);
            events.OnCurrentToolChangedEvent += new OnCurrentToolChangedEventHandler(this.ApplicationEvents_OnCurrentToolChangedEvent);
            events.OnDisplayStatusInfoEvent += new OnDisplayStatusInfoEventHandler(this.ApplicationEvents_OnDisplayStatusInfoEvent);
            events.OnDockWindowEvent += new OnDockWindowEventHandler(this.ApplicationEvents_OnDockWindowEvent);
            events.OnDockWindowAndRefreshEvent += new OnDockWindowAndRefreshEventHandler(this.ApplicationEvents_OnDockWindowAndRefreshEvent);
            events.OnDockWindowAtFixedLocationEvent += new OnDockWindowAtFixedLocationEventHandler(this.ApplicationEvents_OnDockWindowAtFixedLocationEvent);
            events.OnHideDockWindowEvent += new OnHideDockWindowEventHandler(this.ApplicationEvents_OnHideDockWindowEvent);
            events.OnUpdateContentEvent += new OnUpdateContentEventHandler(this.ApplicationEvents_OnUpdateContentEvent);
        }

        public void DelayEvents(bool delay)
        {
            this.m_Delay = delay;
        }

        public void ExecuteCommand(ICommand pCommand)
        {
        }

        private void ApplicationEvents_OnDockWindowAtFixedLocationEvent(object pWindow, Point pt)
        {
        }

        private void ApplicationEvents_OnDisplayStatusInfoEvent(string sInfo)
        {
        }

        private void Application_OnDelayEvents(bool delay)
        {
            this.DelayEvents(delay);
        }


        private void ApplicationEvents_OnDockWindowAndRefreshEvent(object pWindow)
        {
        }


        private void ApplicationEvents_OnHideDockWindowEvent(object pWindow)
        {
        }

        private void ApplicationEvents_OnCurrentToolChangedEvent(ITool pTool)
        {
        }

        private void ApplicationEvents_OnDockWindowEvent(object pWindow)
        {
        }

        private void ApplicationEvents_OnUpdateContentEvent()
        {
            this.UpdateContent();
        }


        public void ResetCurrentTool()
        {
        }

        public void SetHook(object hook)
        {

        }

        public void UpdateContent()
        {

        }
    }
}

